﻿using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using corpus_platform.Data;

namespace corpus_platform.ViewModels
{
    public class ListedFrame : BindableBase
    {
        public ListedFrame(Frame frame, RootViewModel root)
        {
            Root = root;
            Name = frame.Name;
            Information = frame.Information;
            foreach (FrameElement frameElement in frame.FrameElements)
            {
                FrameElements.Add(new ListedFrameElement(frameElement));
            }
        }

        public RootViewModel Root { get; }
        public string Name { get; }
        public string Information { get; }
        public List<ListedFrameElement> FrameElements { get; } = new();

        private DelegateCommand commandToBinding;
        public DelegateCommand CommandToBinding =>
            commandToBinding ?? (commandToBinding = new DelegateCommand(ExecuteCommandToBinding, CanExecuteCommandToBinding));

        void ExecuteCommandToBinding()
        {
            new FrameViewModel(this);
        }

        bool CanExecuteCommandToBinding()
        {
            return true;
        }

    }
}
